Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added two new methods to return Date and Time as a struct and get formatted Date Time string with a given format #94

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the new function names to keywords.txt, using a true tab as a separator between the keyword and the identifier:
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#keywordstxt-format

NTPClient.cpp Outdated Show resolved Hide resolved
NTPClient.h Outdated Show resolved Hide resolved
NTPClient.h Outdated Show resolved Hide resolved
NTPClient.h Outdated Show resolved Hide resolved
@isharasampath
Copy link
Author

Please add the new function names to keywords.txt, using a true tab as a separator between the keyword and the identifier:
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#keywordstxt-format

Added new two methods to the keywords.txt

@per1234 per1234 dismissed their stale review March 20, 2020 08:36

Requested changes made. Thanks!

@isharasampath

This comment was marked as duplicate.

@zzuutt
Copy link

zzuutt commented Apr 23, 2020

Hello,
is it possible to add this possiblility ?
in NTPClient.h
/** * Return the date time from the epochtime value as a String with the given format (Ex: %Y/%m/%d %H:%M:%S) */ String getFormattedDateTime(const char* dateTimeFormat, time_t t) const;

in NTPClient.cpp
String NTPClient::getFormattedDateTime(const char* dateTimeFormat, time_t t = 0) const { struct tm * ts; time_t rawTime = t ? t : this->getEpochTime(); ts = localtime(&rawTime); char buf[64]; strftime(buf, sizeof(buf), dateTimeFormat, ts); return String(buf); }

that may be useful

@isharasampath
Copy link
Author

Hello,
is it possible to add this possiblility ?
in NTPClient.h
/** * Return the date time from the epochtime value as a String with the given format (Ex: %Y/%m/%d %H:%M:%S) */ String getFormattedDateTime(const char* dateTimeFormat, time_t t) const;

in NTPClient.cpp
String NTPClient::getFormattedDateTime(const char* dateTimeFormat, time_t t = 0) const { struct tm * ts; time_t rawTime = t ? t : this->getEpochTime(); ts = localtime(&rawTime); char buf[64]; strftime(buf, sizeof(buf), dateTimeFormat, ts); return String(buf); }

that may be useful

I think this is something more of a utility functions which NTPClient not directly involving. Passing epochtime from outside and getting it formatted is not part of a job in NTPClient.

@CLAassistant
Copy link

CLAassistant commented Apr 9, 2021

CLA assistant check
All committers have signed the CLA.

Copy link

@MPParsley MPParsley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if we could have this in.

'class NTPClient' has no member named 'getFormattedDate'; did you mean 'getFormattedTime'?

@isharasampath
Copy link
Author

Would be nice if we could have this in.

'class NTPClient' has no member named 'getFormattedDate'; did you mean 'getFormattedTime'?

getFormattedDateTime method will return the formatted date, time or datetime string according to the given format.

Ex:
datetime patter: %Y/%m/%d %H:%M:%S or %Y-%m-%d %H:%M:%S
date pattern: %Y/%m/%d
time pattern: %H:%M:%S

@per1234 per1234 added topic: code Related to content of the project itself type: enhancement Proposed improvement labels Jan 30, 2022
@nona00

This comment was marked as duplicate.

@iabe2561

This comment was marked as duplicate.

@m4nzm333

This comment was marked as duplicate.

@dawidadach

This comment was marked as duplicate.

@probonopd

This comment was marked as duplicate.

@nricciardi

This comment was marked as duplicate.

@arduino-libraries arduino-libraries locked as too heated and limited conversation to collaborators Nov 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet